package strategy;

import java.lang.annotation.Annotation;
import java.lang.ref.Reference;
import java.util.HashMap;
import java.util.Map;

public class BaseFactory {

    private final Map<String,Base> baseMap = new HashMap<>();

    private final  Base[] bases;

    public BaseFactory(Base[] bases){
        this.bases = bases;
        for(Base base : bases){
            baseMap.put(base.type(),base);
        }

    }


    public <T extends  BaseResponse> T doAction(BaseRequest baseRequest, String type){
        BaseResponse execute = baseMap.get(type).execute(baseRequest);
        return (T)execute;
    }
}
